package com.hibuy.pc.controller;

import com.hibuy.pc.model.shiro.Permission;
import com.hibuy.pc.service.shiro.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by admin on 2017/12/28.
 */
@Controller
@RequestMapping("permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;



//    @RequestMapping(value = "list",method = RequestMethod.GET)
//    public String toPermission (){
//        return "permission/list";
//    }
//
//    @RequestMapping(value = "list",method = RequestMethod.POST)
//    @ResponseBody
//    public List<Permission> getPermissions (){
//       return permissionService.getPermissions();
//    }

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public String toPermission (HttpServletRequest request){
        request.setAttribute("permission",permissionService.getPermissions());
        return "permission/list";
    }

    @RequestMapping(value = "/add",method = RequestMethod.GET)
    public String addPermission(Permission permission){
        permissionService.addPermission(permission);
        return "";
    }
}
